--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit eff722ee183aa2cadc55487e06fff0f3860c76bd
Parents : 8489f45
Author : Sudo-Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-01-10T18:35:43-06:00
Update backend process spawning in Electron by adding error handling for failed process initiation and allow overriding the Python command in the build script for cross-platform compatibility.
Changes
2 files changed, 16 insertions(+), 3 deletions(-)
Diff
diff --git a/electron/main.js b/electron/main.js
index aec565ea..fecd7232 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -539,11 +539,15 @@ app.whenReady().then(async () => {
}
// spawn executable
- exeChildProcess = await spawn(exe, [
+ exeChildProcess = spawn(exe, [
...requiredArguments, // always provide required arguments
...userProvidedArguments, // also include any user provided arguments
]);
+ if (!exeChildProcess || !exeChildProcess.pid) {
+ throw new Error("Failed to start backend process (no PID).");
+ }
+
// log stdout
var stdoutLines = [];
exeChildProcess.stdout.setEncoding("utf8");
diff --git a/scripts/build-backend.js b/scripts/build-backend.js
index 982310de..700f53c8 100755
--- a/scripts/build-backend.js
+++ b/scripts/build-backend.js
@@ -49,8 +49,11 @@ try {
const buildDirRelative = isWin ? "build/exe/win32" : "build/exe/linux";
const buildDir = path.join(__dirname, "..", buildDirRelative);
+ // Allow overriding the python command (e.g., to use wine python for cross-builds)
+ const pythonCmd = process.env.PYTHON_CMD || "poetry run python";
+
console.log(
- `Building backend for ${platform} (target: ${targetName}, output: ${buildDirRelative}) with cx_Freeze...`
+ `Building backend for ${platform} (target: ${targetName}, output: ${buildDirRelative}) using: ${pythonCmd}`
);
const env = {
@@ -58,7 +61,13 @@ try {
CX_FREEZE_TARGET_NAME: targetName,
CX_FREEZE_BUILD_EXE: buildDirRelative,
};
- const result = spawnSync("poetry", ["run", "python", "cx_setup.py", "build"], {
+
+ // Split pythonCmd to handle arguments like "wine python"
+ const cmdParts = pythonCmd.split(" ");
+ const cmd = cmdParts[0];
+ const args = [...cmdParts.slice(1), "cx_setup.py", "build"];
+
+ const result = spawnSync(cmd, args, {
stdio: "inherit",
shell: false,
env: env,
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────